<template>
	<div class="detail_content" v-loading="boxloading">
		<!-- 返回 -->
		<HyPageHeader :title="deta.title" />
		<!-- 详情区 -->
		<div class="detail_box">
			<div class="detail">
				<div class="detail_left">
					<!-- 应用信息   都有-->
					<div class="Unit_Information">
						<HyCard title="应用信息">
							<Unit :message="data?.info" />
						</HyCard>
					</div>
					<!-- 应用开发前期 填写中后期-->
					<div class="Unit_Information">
						<kouJibmForm :message="data.info" :id="deta?.id" :appCode="deta?.appCode" />
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { getImplementationByCode, checkDataDetail } from '/@/api/Implementation/addImple';
import { changeDetail, terminateDetail } from '/@/api/Implementation/tableImple';
import HyPageHeader from '/@/components/HyPageHeader/index.vue';
import HyCard from '/@/views/digitalList/detail/components/Card.vue';
import Unit from './components/unit.vue';
import kouJibmForm from './components/kouJibmForm.vue';
import { computed, ref, reactive, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute();
const router = useRouter();
onMounted(() => {
	let data = route.query;
	if (!data) {
		return;
	}
	deta.value.id = data.id;
	deta.value.appCode = data.appCode;
	deta.value.instanceId = data.instanceId;
	deta.value.title = data.title;
	deta.value.type = data.type;
	deta.value.tableType = data.tableType;
	// //获取实施待申报详情
	getDetailed();
});
let deta: any = ref({
	title: '数字化申报',
	id: '',
	appCode: '',
	instanceId: '',
	type: 0, //判断由哪个页面跳转过来 0-新增编辑前期资料 1-填写实施中后期 2-应用变更 3-应用终止 4应用验收
	tableType: null, //1开发2运维
	isBj: false, //判断是否是填写中后期资料
	processInstanceId: '',
});
let data = reactive({
	//基本详情信息
	info: {},
	//应用变更
	change: {
		appCode: '',
	},
	//应用终止
	terminate: {
		appCode: '',
	},
	//验收材料
	appCheck: {
		appCode: '',
	},
});
const boxloading = ref(false);
const getDetailed = () => {
	let id = deta.value.id;
	boxloading.value = true;
	checkDataDetail({ implementationId: id, reallyId: -123 })
		.then((res) => {
			boxloading.value = false;
			if (res.code == 0) {
				data.info = res.data.implementation;
				data.appCheck = res.data.implementation?.appCheck;
				//判断有没有应用或终止，1是变更 2是终止
				if (res.data?.implementationChangeLog) {
					if (res.data?.implementationChangeLog.type == 1) {
						data.change = res.data?.implementationChangeLog;
					}
					if (res.data?.implementationChangeLog.type == 2) {
						data.terminate = res.data?.implementationChangeLog;
					}
				}
			}
		})
		.catch((res) => {
			boxloading.value = false;
		});
};

function handleBack() {
	window.history.length > 1 ? router.go(-2) : router.push('/');
}
</script>

<style lang="scss" scoped>
.detail_content {
	width: 100%;
	padding: 15px;
	padding-bottom: 0px;
	position: relative;
	left: 0px;
	top: 0px;
	height: calc(100vh - 90px);
	:deep(.h-full) {
		height: auto;
	}

	.detail_box {
		margin-top: 5px;
		width: 100%;
		height: calc(100vh - 245px);
		display: flex;
		flex-direction: column;
		.review_progress {
			// 评审进度
			margin-top: 20px;
			margin-bottom: 10px;
		}
		.detail {
			flex: 1;
			overflow: auto;

			.detail_left {
				.Unit_Information {
					margin-bottom: 10px;
				}
			}
		}
	}
	.bott_box {
		position: fixed;
		right: 15px;
		bottom: 100px;
		display: flex;
		:deep(.el-button) {
			color: #ffffff;
		}
	}
}
</style>
